package com.army.study.dialog;


import com.army.study.ResourceTable;
import ohos.agp.components.*;
import ohos.agp.window.dialog.CommonDialog;
import ohos.app.Context;
import ohos.media.image.PixelMap;

import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_CONTENT;
import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_PARENT;

/**
 * 预览信件内容
 */
public class PreviewLetterDialog extends CommonDialog {

    public PreviewLetterDialog(Context context, PixelMap imgId) {
        super(context);
        Component container = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_dialog_previce_letter, null, false);
        setContentCustomComponent(container);
        setSize(MATCH_PARENT, MATCH_CONTENT);

        setCornerRadius(AttrHelper.vp2px(20, context));

        Image image = (Image) container.findComponentById(ResourceTable.Id_preview);
        image.setPixelMap(imgId);


        Button btnCancel = (Button) container.findComponentById(ResourceTable.Id_button_dialog_create_file_cancel);
        Button btnConfirm = (Button) container.findComponentById(ResourceTable.Id_button_dialog_create_file_confirm);

        btnCancel.setClickedListener(component -> {	destroy();});
        btnConfirm.setClickedListener(component -> { destroy();});
    }

}
